home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / graphicgems4.lha / GemsIV / vec_mat / ray / Primitive.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-06  |  1.0 KB  |  38 lines

  1. /************************************************************************
  2. *                                    *
  3. * CLASS: Primitive                            *
  4. * AUTHOR: Jean-Francois DOUE                        *
  5. * LAST MODIFICATION: 12 Oct 1993                    *
  6. *                                    *
  7. * This class is an abstract class which defines the basic methods    *
  8. * to which every ray-traceable object (primitive) will have to respond. *
  9. * It also stores the color and the phong coefficients of the primitive    *
  10. *                                    *
  11. ************************************************************************/
  12.  
  13. #ifndef Primitive_h
  14. #define Primitive_h 1
  15. #include "Object3D.h"
  16.  
  17. class Primitive: public Object3D
  18. {
  19. protected:
  20.  vec3    col;        // color of the primitive
  21.  vec4    ph;        // phong coefficients of the object
  22.  
  23. public:
  24.  
  25.  vec3 color() { return col; };
  26.  double phong(int i) { return ph[i]; };
  27.  double closest_intersection(double *x, int x_num);
  28.  
  29.  // virtual methods
  30.  virtual ~Primitive();
  31.  virtual double intersect(vec3& ray_org, vec3& ray_dir) = 0;
  32.  virtual vec3 normalAt(vec3& p) = 0;
  33.  
  34.  // friends
  35.  friend istream& operator >> (istream& s, Primitive& a);
  36. };
  37.  
  38. #endif